//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.family;

import java.awt.BorderLayout;
import javax.swing.*;
import org.jpgolay.gui.fixed.TableViewer;

public class FamilyGUI extends JInternalFrame {

    public FamilyGUI() {
        jContentPane = null;
        jTabbedPane = null;
        itemTableViewer = null;
        customerTableViewer = null;
        supplierTableViewer = null;
        salesPersonTableViewer = null;
        initialize();
    }

    private void initialize() {
        setFrameIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/arrowRight18x18.png")));
        setTitle("FAMILLES");
        setSize(400, 300);
        setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getJTabbedPane(), "Center");
        }
        return jContentPane;
    }

    private JTabbedPane getJTabbedPane() {
        if (jTabbedPane == null) {
            jTabbedPane = new JTabbedPane();
            jTabbedPane.setTabLayoutPolicy(1);
            jTabbedPane.addTab("Articles", new ImageIcon(getClass().getResource("/org/jpgolay/me/images/itemList16x16.png")), getItemTableViewer(), null);
            jTabbedPane.addTab("Clients", new ImageIcon(getClass().getResource("/org/jpgolay/me/images/customerList16x16.png")), getCustomerTableViewer(), null);
            jTabbedPane.addTab("Fournisseurs", new ImageIcon(getClass().getResource("/org/jpgolay/me/images/supplierList16x16.png")), getSupplierTableViewer(), null);
            jTabbedPane.addTab("Commerciaux", new ImageIcon(getClass().getResource("/org/jpgolay/me/images/salesperson18x18.png")), getSalesPersonTableViewer(), null);
        }
        return jTabbedPane;
    }

    private TableViewer getItemTableViewer() {
        if (itemTableViewer == null) {
            itemTableViewer = new TableViewer();
        }
        return itemTableViewer;
    }

    private TableViewer getCustomerTableViewer() {
        if (customerTableViewer == null) {
            customerTableViewer = new TableViewer();
        }
        return customerTableViewer;
    }

    private TableViewer getSupplierTableViewer() {
        if (supplierTableViewer == null) {
            supplierTableViewer = new TableViewer();
        }
        return supplierTableViewer;
    }

    private TableViewer getSalesPersonTableViewer() {
        if (salesPersonTableViewer == null) {
            salesPersonTableViewer = new TableViewer();
        }
        return salesPersonTableViewer;
    }

    public TableViewer getItemTable() {
        return getItemTableViewer();
    }

    public TableViewer getCustomerTable() {
        return getCustomerTableViewer();
    }

    public TableViewer getSupplierTable() {
        return getSupplierTableViewer();
    }

    public TableViewer getSalesPersonTable() {
        return getSalesPersonTableViewer();
    }

    public int getSelectedTable() {
        return getJTabbedPane().getSelectedIndex();
    }
    private JPanel jContentPane;
    private JTabbedPane jTabbedPane;
    private TableViewer itemTableViewer;
    private TableViewer customerTableViewer;
    private TableViewer supplierTableViewer;
    private TableViewer salesPersonTableViewer;
}
